import { request } from "@/utils/service"
import type {
  CreateOrder,
  OrderRespPageData,
  PayOrdersData, PayOrdersReqData, PayOrdersReqListData,
  PayOrdersReqPageData, PayOrdersRespListData,
  PayOrdersRespPageData
} from "@/api/orders/types";



// 创建订单
export function createPayOrders(data: CreateOrder) {
  return request<string>({
    url: '/private/pay/pay-orders/create',
    method: 'POST',
    data: data
  })
}

// 更新订单
export function updatePayOrders(data?: PayOrdersData) {
  return request<boolean>({
    url: '/private/pay/pay-orders/update',
    method: 'PUT',
    data: data
  })
}

// 删除订单
export function deletePayOrders(id?: string) {
  return request({
    url: '/private/pay/pay-orders/delete?id=' + id,
    method: 'DELETE'
  })
}

// 获得订单
export function getPayOrders(id?: string) {
  return request<CreateOrder>({
    url: '/private/pay/pay-orders/get?id=' + id,
    method: 'GET'
  })
}


// 获得订单分页
export function getPayOrdersPage(query: PayOrdersReqPageData) {
  return request<PayOrdersRespPageData>({
    url: '/private/pay/pay-orders/page',
    method: 'GET',
    data: query
  })
}
export function getOrdersPage(query: PayOrdersReqPageData) {
  return request<OrderRespPageData>({
    url: '/private/pay/pay-orders/page',
    method: 'GET',
    data: query
  })
}


// 获得订单列表
export function getPayOrdersList(query: PayOrdersReqListData) {
  return request<PayOrdersRespListData>({
    url: '/private/pay/pay-orders/list',
    method: 'GET',
    data: query
  })
}


// 导出订单 Excel
export function exportPayOrdersExcel(query: PayOrdersReqData) {
  return request({
    url: '/private/pay/pay-orders/export-excel',
    method: 'GET',
    data: query,
    responseType: 'blob'
  })
}

// 获得微信支付的订单信息
export function getPayWeChatInfo(bh?: string) {
  return request<string>({
    url: '/public/wechat/wx-pay-info?bh=' + bh,
    method: 'GET'
  })
}
// 获得支付宝的订单信息

export function getPayAliInfo(bh?: string) {
  return request<string>({
    url: '/public/alipay/alipay-info?bh=' + bh,
    method: 'GET'
  })
}

// 查询支付宝支付结果
export function queryPayAliResult(bh?: string) {
  return request<string>({
    url: '/public/alipay/query?bh=' + bh,
    method: 'GET'
  })
}

// 查询微信支付结果
export function queryPayWeChatResult(bh?: string) {
  return request<string>({
    url: '/public/wechat/query?bh=' + bh,
    method: 'GET'
  })
}